/*
 * @Author: Kilims Ye
 * @LastEditors: Kilims Ye
 * @Date: 2020-04-14 10:46:44
 * @LastEditTime: 2021-01-27 15:54:47
 * @Description: 
 */
import React from "react"
import styled from "styled-components";

const Loader = styled.div`
  border-radius: 50%;
  width: 5em;
  height: 5em;
  /* margin: 60px auto; */
  margin-bottom: 0.3rem;
  font-size: 10px;
  position: relative;
  text-indent: -9999em;
  border-top: 0.55em solid ${props => props.loaderBorderColor};
  border-right: 0.55em solid ${props => props.loaderBorderColor};
  border-bottom: 0.55em solid ${props => props.loaderBorderColor};
  border-left: 0.55em solid ${props => props.loaderColor};
  -webkit-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-animation: load8 1.1s infinite linear;
  animation: load8 1.1s infinite linear;
  :after {
    border-radius: 50%;
    width: 5em;
    height: 5em;
  }
@-webkit-keyframes load8 {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes load8 {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
`

const Wrapper = styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
`

function LoaderComponent(props) {
  const {
    loaderColor,
    loaderBorderColor,
    text,
  } = props
  return (
    <Wrapper>
      <Loader loaderColor={loaderColor} loaderBorderColor={loaderBorderColor} />
      {text ? props.text : "请稍候..."}
    </Wrapper>
  )
}

LoaderComponent.defaultProps = {
  loaderColor: "#DF0A1A",
  loaderBorderColor: "#fff",
  text: null,
}

export default LoaderComponent